import pytest
import requests
''''
测试注册功能
'''''

@pytest.fixture(params=[{"data": {"mobilephone": "17692215822", "pwd": "123456"},
                         "expect": {"status": 1, "code": "10001", "msg": "注册成功"}},
                        {"data": {"mobilephone": "1559221582", "pwd": "123456"},
                         "expect": {"status": 0, "code": "20109", "msg": "手机号码格式不正确"}},
                        {"data": {"mobilephone": "", "pwd": "123456"},
                         "expect": {"status": 0, "code": "20103", "msg": "手机号不能为空"}},
                        {"data": {"mobilephone": "15592215821", "pwd": "123456"},
                         "expect": {"status": 0, "code": "20110", "msg": "手机号码已被注册"}}])
def login_data1(request): # 参数名是固定的，不能随意更改
    print("开始测试")
    return request.param # 这里的return关键字是返回值，可以返回每一组的测试数据

def test_login2(login_data1): # login_data1是字典
    print(f"测试注册的功能，测试数据为：{login_data1}")
    url = "http://192.168.65.1:8088/futureloan/mvc/api/member/register"
    r = requests.get(url, params=login_data1['data'])
    print(r.json())
    assert r.json()['msg'] == login_data1['expect']['msg']
    assert r.json()['status'] == login_data1['expect']['status']
    assert r.json()['code'] == login_data1['expect']['code']